home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / qbnewsl / qbnws102 / qexec / qexec.asm < prev    next >
Assembly Source File  |  1989-12-02  |  5KB  |  88 lines

  1.              Page   60, 130
  2.               EXTRN  Pascal B$ShellSetup:Far
  3.               EXTRN  Pascal B$ShellRecover:Far
  4.      .MODEL   MEDIUM,BASIC
  5.               .CODE
  6.  
  7.      Qexec    Proc    Far Uses DS ES SI DI, Arg1:Ptr
  8.               Jmp     Start
  9.  
  10.      HoldRC   DW      0
  11.  
  12.      Pars     DW      0                      ;Environment segment
  13.      CmdLine  DW      0                      ;Command line for child - length
  14.      CmdLineS DW      0                      ;  Command line text
  15.               DW      5CH                    ;Default FCB 1 offset
  16.      Fcb1     DW      0                      ;FCB 1 segment address
  17.               DW      6CH                    ;Default FCB 2 offset
  18.      Fcb2     DW      0                      ;FCB 2 segment address
  19.  
  20.      PgmTxt   DB      65 Dup(?)              ;Work area to build pgm string
  21.  
  22.      CmdBuf   DB      ?                      ;This will hold the length
  23.               DB      ' '                    ;Must allow one space
  24.      CmdTxt   DB      80 Dup(?)              ;The command line text
  25.  
  26.      Start:   Mov     CS:HoldRC,-1           ;Set RC to -1
  27.               Mov     BX,Arg1                ;Get Program name length
  28.               Mov     CX,[BX]                ;  in CX
  29.               Jcxz    GetOut                 ;Error - Get out
  30.               Mov     SI,[BX+2]              ;Address of Program string
  31.               Mov     DI,Offset PgmTxt       ;Program text buffer
  32.               Push    ES                     ;Save ES register
  33.               Mov     AX,CS                  ;Make the ES register
  34.               Mov     ES,AX                  ;   the same as the CS register
  35.  
  36.      Pline:   Lodsb                          ;Get a character
  37.               Cmp     AL,' '                 ;Is it a space?
  38.               Je      Pline1                 ;Yes - go to next routine
  39.               Stosb                          ;Move to buffer
  40.               Loop    Pline                  ;Do it again
  41.  
  42.      Pline1:  Xor     AX,AX                  ;Zero out AX register
  43.               Stosb                          ;Make PgmTxt an ASCIIZ string
  44.               Jcxz    Pline2                 ;No more - continue
  45.               Dec     CX                     ;Adjust for space
  46.  
  47.      Pline2:  Mov     CS:CmdBuf,CL           ;Save command tail length
  48.               Mov     DI,Offset CmdTxt       ;Command tail buffer
  49.               Jcxz    Tline                  ;No more - continue
  50.               Rep     Movsb                  ;Move command tail to buffer
  51.      Tline:   Inc     CS:CmdBuf              ;Add one to tail length
  52.               Mov     AL,13                  ;CR value in AL
  53.               Stosb                          ;Move to buffer
  54.               Pop     ES                     ;Restore ES register
  55.               Mov     DI,Offset CmdBuf       ;New command tail
  56.               Mov     CS:CmdLine,DI          ;Move address to parameter block
  57.               Mov     DI,CS                  ;Get CS register address
  58.               Mov     CS:CmdLineS,DI         ;Move address to parameter block
  59.               Mov     AH,62H                 ;Get current PSP segment
  60.               Int     21H                    ;DOS interrupt
  61.               Mov     CS:Fcb1,BX             ;Move PSP address to param block
  62.               Mov     CS:Fcb2,BX             ;Move PSP address to param block
  63.               Call    B$ShellSetup           ;QB routine to compress memory
  64.               Mov     DX,Offset PgmTxt       ;DX points to program name string
  65.               Mov     BX,Offset Pars         ;BX points to child environment
  66.               Push    DS                     ;Save DS register
  67.               Mov     AX,CS                  ;Put CS register address
  68.               Mov     ES,AX                  ;   into the ES register
  69.               Mov     DS,AX                  ;   into the DS register
  70.               Mov     AH,4BH                 ;Function 4B - EXEC function
  71.               Mov     AL,00H                 ;Sub Function 0 - load & exec pgm
  72.               Int     21H                    ;DOS interrupt
  73.               Pop     DS                     ;Restore DS register
  74.               Jnc     Cont                   ;No Error - Continue
  75.               Mov     AH,-1                  ;Set AH = FFh
  76.               Jmp     Cont1                  ;Error - Get out
  77.      Cont:    Mov     AH,4DH                 ;Function 4D - Get child errorlevel
  78.               Int     21H                    ;DOS interrupt
  79.               Xor     AH,AH                  ;Zero out AH register
  80.      Cont1:   Mov     CS:HoldRC,AX           ;Set RC to -1
  81.               Call    B$ShellRecover         ;QB routine to uncompress memory
  82.  
  83.      GetOut:  Mov     AX,CS:HoldRC           ;Set the return code
  84.               Ret                            ;Go back to caller
  85.  
  86.      Qexec    Endp
  87.               End
  88.